package com.mobimagic.lockscreen.view;

import android.graphics.Canvas;
import android.graphics.Paint;

public class Bubble {
    //气泡半径
    private float radius;
    //气泡x坐标
    private float x;
    //气泡y坐标
    private float y;
    //水平移动速度
    private float speedX;
    //垂直移动速度
    private float speedY;
    //随机颜色
    private int color;
    private boolean visible;

    public boolean isVisible() {
        return visible;
    }

    public void setVisible(boolean visible) {
        this.visible = visible;
    }

    public Bubble() {
        resetSpeed();
    }

    public void resetSpeed() {
        float speedX = (float) ((Math.random() - 0.5f) * 0.1f);
        setSpeedX(speedX);
    }

    public float getRadius() {
        return radius;
    }

    public void setRadius(float radius) {
        this.radius = radius;
    }

    public float getX() {
        return x;
    }

    public void setX(float x) {
        this.x = x;
    }

    public float getY() {
        return y;
    }

    public void setY(float y) {
        this.y = y;
    }

    public float getSpeedX() {
        return speedX;
    }

    public void setSpeedX(float speedX) {
        this.speedX = speedX;
    }

    public float getSpeedY() {
        return speedY;
    }

    public void setSpeedY(float speedY) {
        this.speedY = speedY;
    }

    public int getColor() {
        return color;
    }

    public void setColor(int color) {
        this.color = color;
    }

    @Override
    public String toString() {
        return "Bubble [radius=" + radius + ", x=" + x + ", y=" + y + ", speedX=" + speedX + ", speedY=" + speedY + "]";
    }

    public void draw(Canvas canvas, Paint paint) {
        if (isVisible()) {
            paint.setColor(color);
            canvas.drawCircle(getX(), getY(), getRadius(), paint);
        }
    }
}